import React, {PureComponent} from 'react';
import {Navigate} from "react-router-dom";

class Login extends PureComponent {
    constructor(props) {
        super(props);
        this.state = { isLogin: false };
    }

    render() {

        const { isLogin } = this.state;

        return (
            <div>
                <h1>Login Page</h1>
                <button onClick={e => this.setState({isLogin: true})}>登录</button>
                {isLogin && <Navigate to='/home'/>}
                {isLogin && <h1>Success!</h1>}
            </div>
        );
    }
}

export default Login;